  
  <%require 'htmlentities'
  coder = HTMLEntities.new
  %>
<div class="listings-search-results" id="listings-search-results">
              	<div class="sort-listings">
        	<div class="total-results-count">
              <%if !params[:page].nil?
              a=params[:page].to_i
                b=10
                c=a*b
              else
                c=10
                a=1
              end
              -%>
              <%=a -%> - <%=c-%>  out of <%=@total_ads -%>
            </div>
            <div class="page-navigator"><%= will_paginate(@advertisments,:params=>{:keyword=>params[:keyword],:location=>params[:location],:sub_category=>params[:sub_category],:category=>params[:category],:university=>params[:university]},:remote => true,:update=>"listings-search-results") -%></div>
            <div class="sort-by">
            	<div class="sort-by-name">
                	Sort by:&nbsp;
                </div>
                <div class="sort-by-options">
                	<select>
                        <option value="1">By Date</option>
                        <option value="2">By Relevance</option>
                    </select>
               </div>
            </div>
    	</div>
             <% @advertisments.each do |ad| %>
          
               <%if ad.featured==true %>
        	<div class="sponsored-ad-container" id="sponsored-ad-container_<%=ad.id.to_s%>">
            	<div class="listings-ad-title">
                <%=link_to h(coder.decode(ad.title.capitalize)), { :controller=> "advertisments" , :action=>"show" ,:id => ad} -%>
                </div>
                <div class="ad-posted-fields">
                	<div class="ad-category-details">
					<a href="">	<%= h @category.name -%> / <%= h SubCategory.find(ad.sub_category_id).name %></a>
                    </div>
                	<div class="listings-posted-details">
                    	<div class="listings-posted-text">
                        	Posted on:&nbsp;
                        </div>
                        <div class="listings-posted-value">
                        	<%=h ad.created_at.to_formatted_s(:long_ordinal) -%>
                        </div>
                    </div>
                  	<div class="listings-posted-details">
                    	<div class="listings-posted-text">
                        	Posted by:&nbsp;
                        </div>
                        <div class="listings-posted-value">

                          <%=@user=User.find_by_id(ad.user_id)
                            @full_name=@user.full_name-%>


                        </div>
                    </div>
                </div>
                <div class="listings-ad-fields">
                	<div class="listings-ad-field-one">
                    	<div class="ad-fields-name">
                        	Location:&nbsp;
                        </div>
                        <div class="ad-fields-value">
                        	<%=h ad.location -%>
                        </div>
                    </div>
                	<div class="listings-ad-field-one">
                    	<div class="ad-fields-name">
                        	Company:&nbsp;
                        </div>
                        <div class="ad-fields-value">
                        	HCL Technologies
                        </div>
                    </div>
                	<div class="listings-ad-field-one">
                    	<div class="ad-fields-name">
                        	Industry:&nbsp;
                        </div>
                        <div class="ad-fields-value">
                        	IT Softwares/Software services
                        </div>
                    </div>
                </div>
                <div class="listings-ad-description-sponsored">
                	 <%=h coder.decode(excerpt(ad.description.capitalize  , ' ', 300))unless ad.description.nil? -%>

                     <%=link_to "More", { :controller=> "advertisments" , :action=>"show" ,:id => ad} -%>

                     <%=link_to image_tag("read-more.jpg", :width=>"6px", :height=>"7px",:border=>"0px"), :controller=> "advertisments" , :action=>"show" ,:id => 'ad' -%>

                 </div>
                 <div class="listings-ad-image">

                 	<%#=image_tag @image, :width=>"80",:height=>"80" -%>
                 </div>
                 <div class="listings-contact-advertiser-container">
                     <div class="listings-contact-advertiser">
                         <%=image_tag "contact-advertiser.jpg", :style=>"cursor:pointer;",:width=>"156",:height=>"28",:onclick=>"$('contact_"+ad.id.to_s+"').style.display='block';$('sponsored-ad-container_"+ad.id.to_s+"').style.height='600px'" -%>

                     </div>
                     <div class="save-similar-links">
                        <%=link_to "Save Ad", "javascript:openSave("+ad.id.to_s+");" -%>&nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="">View Similar Ads</a>
                     </div>
                 </div>
                 <div id="contact_<%=ad.id.to_s%>" class="listings-contact-advertiser-form">

                   <div class="contact-form-container">

                          <div class="contact-form-tabs">
                            <ul>
                              <li class="selected-tab"> <%=link_to image_tag("email-and-sms.jpg", :border=>"0px") + "&nbsp;&nbsp;E-mail and SMS", "#" -%></li>
                              <li><%=link_to image_tag("get-phone-number.jpg", :border=>"0px") + "&nbsp;&nbsp;Get Phone Number", "#" -%></li>
                            </ul>
                          </div>
                          <div class="contact-form">
                          <% form_tag url_for(:controller => "queries",  :action => "create" , :advertisment_id => ad.id), :multipart => true do  %>
                          <div class="message">Contact this business with your requirements and queries.</div>
                          <div class="form-inputs">
                              <%=text_field :user, :full_name ,:size => 28,:class=>"your-name",:value=> (session[:user].nil? ? "Your name*"  : session[:user].full_name) , :maxlength=>"40" -%>
                              <%=text_field :user, :email     ,:size => 28,:class=>"e-mail-id",:value=> (session[:user].nil? ? "E-mail ID*"  : session[:user].email)     , :maxlength=>"40" -%>
                              <%=text_field :user, :mobile_no ,:size => 20,:class=>"mobile-no",:value=> (session[:user].nil? ? "Mobile No.*" : session[:user].mobile_no) , :maxlength=>"10" -%>
                              <div class="query">
                                <%=text_area :query, :content , :size => "55x3"  ,:wrap=> "virtual",:value=>"Message*\n\Please provide a detailed response to get a better reply"%>
                              </div>
                             <div class="attach"><%=link_to image_tag("Attach.jpg", :border=>"0px") + "Attach a file", "javascript:void(0);",:onclick=>"Element.show('attach-field_"+ad.id.to_s+"');"-%></div>
                             <div class="attach-field" style="display:none;" id="attach-field_<%=ad.id.to_s%>">
                              <%=file_field(:attachment,:file,:class=>"e-mail-id") -%>
                             </div>
                          </div>
                              <div class="send-message"><%= image_submit_tag("send-message.jpg") -%></div>
                              <%end -%>
                          </div>
                    </div>
                 </div>


           </div>
<%end -%>
 <%end -%>
 <% @advertisments.each do |ad| %>

               <%if ad.featured==false %>

           
        	<div class="listings-ad-container" id="listings-ad-container_<%=ad.id.to_s%>">
            	<div class="listings-ad-title">
                	<%=link_to h(coder.decode(ad.title.capitalize)), { :controller=> "advertisments" , :action=>"show" ,:id => ad} -%>
                </div>

                <div class="ad-posted-fields">
                	<div class="ad-category-details">
							<a href="">	<%= h @category.name -%> /<%= h SubCategory.find(ad.sub_category_id).name %></a>
                    </div>
                	<div class="listings-posted-details">
                    	<div class="listings-posted-text">
                        	Posted on:&nbsp;
                        </div>
                        <div class="listings-posted-value">
                        	<%=h ad.created_at.to_formatted_s(:long_ordinal) -%>
                        </div>
                    </div>
                  	<div class="listings-posted-details">
                    	<div class="listings-posted-text">
                        	Posted by:&nbsp;
                        </div>
                        <div class="listings-posted-value">
                          <%=@user=User.find_by_id(ad.user_id)
                            @full_name=@user.full_name-%>

                        </div>
                    </div>
                </div>
                <div class="listings-ad-fields">
                	<div class="listings-ad-field-one">
                    	<div class="ad-fields-name">
                        	Location:&nbsp;
                        </div>
                        <div class="ad-fields-value">
                        	<%=h ad.location -%>
                        </div>
                    </div>
                	<div class="listings-ad-field-one">
                    	<div class="ad-fields-name">
                        	Company:&nbsp;
                        </div>
                        <div class="ad-fields-value">
                        	HCL Technologies
                        </div>
                    </div>
                	<div class="listings-ad-field-one">
                    	<div class="ad-fields-name">
                        	Industry:&nbsp;
                        </div>
                        <div class="ad-fields-value">
                        	IT Softwares/Software services
                        </div>
                    </div>
                </div>
                <div class="listings-ad-description">

                <%=h coder.decode(excerpt(ad.description.capitalize  , ' ', 300))unless ad.description.nil? -%>

                <%=link_to "More", { :controller=> "advertisments" , :action=>"show" ,:id => ad} -%>
                <%=link_to image_tag("read-more.jpg", :width=>"6px", :height=>"7px",:border=>"0px"), :controller=> "advertisments" , :action=>"show" ,:id => ad -%>

                 </div>
                 <div class="listings-contact-advertiser-container">
                   <div class="listings-contact-advertiser">
                     <%=image_tag("contact-advertiser.jpg", :width=>"156px",:style=>"cursor:pointer;", :height=>"28px",:border=>"0px" , :onclick=>"$('contact_"+ad.id.to_s+"').style.display='block';$('listings-ad-container_"+ad.id.to_s+"').style.height='600px'" )%>

                   </div>
                   <div class="save-similar-links">
                     <%=link_to "Save Ad", "javascript:openSave("+ad.id.to_s+");" -%>&nbsp;&nbsp;&nbsp;&nbsp;

                      <a href="">View Similar Ads</a>
                   </div>
                 </div>
                 <div id="contact_<%=ad.id.to_s%>" class="listings-contact-advertiser-form">


                   <div class="contact-form-container">

                          <div class="contact-form-tabs">
                            <ul>
                              <li class="selected-tab"> <%=link_to image_tag("email-and-sms.jpg", :border=>"0px") + "&nbsp;&nbsp;E-mail and SMS", "#" -%></li>
                              <li><%=link_to image_tag("get-phone-number.jpg", :border=>"0px") + "&nbsp;&nbsp;Get Phone Number", "#" -%></li>
                            </ul>
                          </div>
                          <div class="contact-form">
                          <% form_tag url_for(:controller => "queries",  :action => "create" , :advertisment_id => ad.id), :multipart => true do  %>
                          <div class="message">Contact this business with your requirements and queries.</div>
                          <div class="form-inputs">
                              <%=text_field :user, :full_name ,:size => 28,:class=>"your-name",:value=> (session[:user].nil? ? "Your name*"  : session[:user].full_name) , :maxlength=>"40" -%>
                              <%=text_field :user, :email     ,:size => 28,:class=>"e-mail-id",:value=> (session[:user].nil? ? "E-mail ID*"  : session[:user].email)     , :maxlength=>"40" -%>
                              <%=text_field :user, :mobile_no ,:size => 20,:class=>"mobile-no",:value=> (session[:user].nil? ? "Mobile No.*" : session[:user].mobile_no) , :maxlength=>"10" -%>
                              <div class="query">
                                <%=text_area :query, :content , :size => "55x3"  ,:wrap=> "virtual",:value=>"Message*\n\Please provide a detailed response to get a better reply"%>
                              </div>
                             <div class="attach"><%=link_to image_tag("Attach.jpg", :border=>"0px") + "Attach a file", "javascript:void(0);",:onclick=>"Element.show('attach-field_"+ad.id.to_s+"');"-%></div>
                             <div class="attach-field" style="display:none;" id="attach-field_<%=ad.id.to_s%>">
                              <%=file_field(:attachment,:file,:class=>"e-mail-id") -%>
                             </div>
                          </div>
                              <div class="send-message"><%= image_submit_tag("send-message.jpg") -%></div>
                              <%end -%>
                          </div>
                    </div>

                 </div>
            </div>
            <%#*<hr size="1" color="#cccccc">%>
            <%end -%>
             <%end -%>
                	<div class="sort-listings">
        	<div class="total-results-count">
              <%if !params[:page].nil?
              a=params[:page].to_i
                b=10
                c=a*b
              else
                c=10
                a=1
              end
              -%>
              <%=a -%> - <%=c-%>  out of <%=@total_ads -%>
            </div>
            <div class="page-navigator"><%= will_paginate @advertisments -%></div>
            <div class="sort-by">
            	<div class="sort-by-name">
                	Sort by:&nbsp;
                </div>
                <div class="sort-by-options">
                	<select>
                        <option value="1">By Date</option>
                        <option value="2">By Relevance</option>
                    </select>
               </div>
            </div>
    	</div>
		</div>